<?php

namespace app\qsapi\controller;


use app\qsapi\model\BaseModel;
use app\qsapi\service\MyGameService;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\DbException;
use think\response\Json;


/**
 * 游戏模块
 */
class MyGame extends BaseController
{
    protected $noNeedLogin = [''];


    /**
     * 我玩过的游戏列表
     * @return Json
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function gamesPlayedList(): Json
    {
        $gameService = new MyGameService();
        return json($gameService->playedList($this->request->getMemberId(), $this->request->get()));
    }

    /**
     * 我看过的列表
     * @return Json
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function seenList(): Json
    {
        $gameService = new MyGameService();
        return json($gameService->seenList($this->request->getMemberId(), $this->request->get()));
    }

    /**
     * 启动游戏,埋点接口
     * @return Json
     */
    public function startGamePoint(): Json
    {
        $gameService = new MyGameService();
        $userId = $this->request->post('user_id') ?? 0;
        $game_id = $this->request->post('game_id') ?? 0;
        return json($gameService->startGame($this->request->getMemberId(), $userId, $game_id));
    }

    /**
     * 查看资料或专区,埋点接口
     * @return Json
     */
    public function seenInfoPoint()
    {
        $gameService = new MyGameService();
        return json($gameService->seenInfo($this->request->getMemberId(), $this->request->post()));
    }

    /**
     * 卸载游戏记录
     * @return Json
     */
    public function unloadGame(): Json
    {
        $gameService = new MyGameService();
        return json($gameService->unloadGame($this->request->getMemberId(), $this->request->post()));
    }

    /**
     * Desc : 获取当前游戏的包ID
     * User : Steven
     * Date : 2024-08-06 14:52
     * @return Json
     */
    public function getPackageId(): Json
    {
        $gameService = new MyGameService();
        return json($gameService->getPackageId($this->request->getMemberId(),$this->request->get()));
    }
}
